home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13249 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.7 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.eiffel,comp.lang.c,comp.lang.c++,comp.object,comp.software-eng
  4. Subject: Re: Beware of "C" Hackers -- A rebuttal to Bertrand Meyer
  5. Date: 24 Mar 1996 07:08:47 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4j3ohvINN4vu@keats.ugrad.cs.ubc.ca>
  8. References: <1995Jul3.034108.4193@rcmcon.com> <4i862r$1evq@saba.info.ucla.edu> <64ss5$3F3RB@herold.franken.de> <314DADD4.3DE@oc.com>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <314DADD4.3DE@oc.com>, Larry Weiss  <lfw@oc.com> wrote:
  12.  >Joachim Durchholz wrote:
  13.  >
  14.  > > There is one trait among many hackers that will make method gurus uneasy -
  15.  > > they don't like to be restricted.
  16.  > > This makes C popular among hackers - it gives many benefits of discipline
  17.  > > (many opportunities for the compiler to do type checking), but allows
  18.  > > evading the restrictions whenever necessary (type casts).
  19.  >
  20.  >
  21.  >What do C hackers think about the new freedom (since the publication of
  22.  >the C Standard) that compilers have to "inline" standard library calls,
  23.  >thereby making it hard for hackers to provide their own variations of
  24.  >any standard library "function" ?
  25.  >
  26.  >In the old days, when the Standard library was just another set of linkable
  27.  >entry points, it was straightforward to replace the vendor's logic with
  28.  >your own (maybe just the same with tracepoint logic, but maybe a very 
  29.  >experimental replacement, and maybe a "better" one).   No more!
  30.  
  31. But you get the benefit of inlined, optimized memcpy() operations, and others!
  32.  
  33.  >What is the position of other languages with respect to their equivalent
  34.  >of the "Standard library" ?   Can I hack the runtime support in other
  35.  
  36. In some languages, the ``standard library'' cannot even be _written_ in the
  37. language. Try writing a Pascal function that is compatible with writeln(), for
  38. instance. How could you do it when there is special syntax for specifying the
  39. format for the arguments?
  40.  
  41.         writeln('Total: ', dollars:8:2);
  42.  
  43.  >languages today more easily than I can the C runtime?
  44.  
  45. Yes, because the standard makes a clear distinction between ``freestanding''
  46. and ``hosted'' C environments.
  47.  
  48. In a freestanding implementation, most of the standard library functions are
  49. not predefined. So there is still the sense of a language core that is free of
  50. special operators.
  51.  
  52. In a hosted environment, you can still redefine a standard function, but the
  53. definition must be restricted to static scope.
  54.  
  55. Many environments let you redefine the functions anyway.
  56.  
  57. Under GCC, the -fno-builtin option will turn off the special treatment of those
  58. functions that are affected in that particular implementation. Most of the
  59. library functions are always done through library calls; only a small subset is
  60. inlined. From an outdated GCC man page, here is what you can glean:
  61.  
  62.       -fno-builtin
  63.            Don't recognize built-in functions that do  not  begin  with  two
  64.            leading  underscores.   Currently, the functions affected include
  65.            _exit, abort, abs, alloca, cos, exit, fabs, labs, memcmp, memcpy,
  66.            sin, sqrt, strcmp, strcpy, and strlen.
  67.  
  68.            The `-ansi' option prevents alloca and _exit from  being  builtin
  69.            functions.
  70.  
  71. In GCC, this would be your ``escape hatch'', guaranteeing that every instance
  72. of memcpy() will call for external linkage.
  73.  
  74. Any standard function that is not in the list is one you can redefine under
  75. this implementation, and you can be confident that all your object files will
  76. use the new function
  77.  
  78. The above are ones you wouldn't want to redefine anyway.  I doubt you could
  79. make a better strcpy() or abs() than compiler-generated inline code! 
  80. -- 
  81.  
  82.